import wepy from 'wepy'
import '@/baseAPI.js'
export default class extends wepy.mixin {
    data = {
            // 轮播图数组
            swiperList: [],
            // 分类数组
            cateItems: [],
            // 楼层数据
            floorData: []
        }
        // 获取首页轮播图
    async getSwiperList() {
        // const { data: res } = await wepy.request({
        //     url: 'https://www.zhengzhicheng.cn/api/public/v1/home/swiperdata'
        // })
        const { data: res } = await wepy.get('/home/swiperdata')
        if (res.meta.status !== 200) {
            return wepy.baseToast()
        }
        this.swiperList = res.message
        this.$apply()
    }

    // 获取分类
    async getCateItems() {
        // const { data: res } = await wepy.request({
        //     url: 'https://www.zhengzhicheng.cn/api/public/v1/home/catitems'
        // })
        const { data: res } = await wepy.get('/home/catitems')
        console.log(res)
        if (res.meta.status !== 200) {
            return wepy.baseToast()
        }
        this.cateItems = res.message
        this.$apply()
    }

    // 获取楼层数据
    async getFloorData() {
        const { data: res } = await wepy.get('/home/floordata')
        if (res.meta.status !== 200) {
            return wepy.baseToast()
        }
        this.floorData = res.message
        this.$apply()
    }

    onLoad() {
        this.getSwiperList()
        this.getCateItems()
        this.getFloorData()
    }

    methods = {
        goGoodsList(url) {
            wepy.navigateTo({ url })
        }
    }
}